import { SecurityStatus } from '@/services/Detail/index';
import { Button, Drawer, Form, Input, message } from 'antd';
interface BindChannelgProps {
  open: boolean;
  onClose: (itemDetail: any) => void;
  detail: any;
}
const { TextArea } = Input;

const PopupRight = (props: BindChannelgProps) => {
  const { open, onClose, detail } = props;
  const onFinish = async (values: any) => {
    try {
      SecurityStatus({
        id: detail.id,
        securityStatus: 0,
        securityRemark: values.refundReason,
      }).then((res) => {
        if (res) {
          message.success('操作成功');
          onClose(true);
        }
      });
    } catch (error) {
      console.log(error);
    }
  };
  return (
    <Drawer
      title={`解除冻结 ${detail.name}`}
      placement="right"
      closable={false}
      onClose={onClose}
      open={open}
      width="40%"
      getContainer={false}
    >
      <Form onFinish={onFinish} labelCol={{ span: 5 }}>
        <Form.Item<any>
          label="备注"
          rules={[{ required: false, message: '备注' }]}
          name="refundReason"
        >
          <TextArea placeholder="备注" maxLength={255}></TextArea>
        </Form.Item>

        <div style={{ height: '50px' }}>
          <div
            style={{
              height: '50px',
              position: 'absolute',
              left: 0,
              bottom: 0,
              width: '100%',
              display: 'flex',
              alignItems: 'center',
              padding: '0 20px',
              borderTop: '1px solid #e8e8e8',
            }}
          >
            <Button type="primary" ghost={true} onClick={onClose}>
              取消
            </Button>
            <Button
              type="primary"
              htmlType="submit"
              style={{ marginLeft: '10px' }}
            >
              确认
            </Button>
          </div>
        </div>
      </Form>
    </Drawer>
  );
};

export default PopupRight;
